module TestSudoku

where

import Control.Monad
import List
import Sudoku
import Test.QuickCheck
import Test.QuickCheck.Arbitrary

main :: IO ()
main = do
  --showGrid (getSolvedSudoku example1)

  --putStr $ show (compareSudokus (getSolvedSudoku example1) (reverseRows (getSolvedSudoku (reverseRows example1))))

  --putStr $ show (length (solveGrid example2) > 0)
  --putStr $ show (length (solveGrid peterExample) > 0)
  --putStr $ show (length (solveGrid saturdaysExample) > 0)

getSolvedSudoku :: Grid -> Grid
getSolvedSudoku sudokuToSolve = sequence $ fmap sud2grid (fst (solveGrid sudokuToSolve))

compareSudokus :: Grid -> Grid -> Bool
compareSudokus expected actual = expected == actual

reverseRows :: Grid -> Grid
reverseRows sudoku = reverse sudoku

reverseColumns :: Grid -> Grid
reverseColumns sudoku = rowsIntoColumns (reverseRows (rowsIntoColumns sudoku))

reverseElementsRows :: Grid -> Grid
reverseElementsRows [] = []
reverseElementsRows sudoku = [reverse (head sudoku)] ++ reverseElementsRows (tail sudoku)

reverseElementsColumns :: Grid -> Grid
reverseElementsColumns sudoku = rowsIntoColumns (reverseElementsRows (rowsIntoColumns sudoku))

rowsIntoColumns :: Grid -> Grid
rowsIntoColumns [[],[],[],[],[],[],[],[],[]] = []
rowsIntoColumns sudoku = [map head sudoku] ++ rowsIntoColumns (map tail sudoku)
